package com.xuzhijie.pms.entity.vo;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.generator.IFill;
import com.xuzhijie.pms.entity.Property;
import lombok.Data;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Data
public class PropertyVo {


    private String id;
    private String detail;
    private LocalDateTime createTime;
    private Integer checkIn;
    private String buildingNo;
    private String number;
    private LocalDate checkInTime;
    private String version;
    private String isDelete;
    private String owner;
    private String propertyType;
    private Double area;
    private Integer renovationStatus;
    private String[] images;
    public PropertyVo(Property property){
        if (property.getType().equals(1)){
            this.propertyType = "仓库";
        }
        if (property.getType().equals(2)){
            this.propertyType = "车位";
        }
        if (property.getType().equals(3)){
            this.propertyType = "住宅";
        }
        if (property.getType().equals(4)){
            this.propertyType = "商户";
        }
        if (property.getType().equals(5)){
            this.propertyType = "车库";
        }

        if (property.getImgs() != null) {
            String str = property.getImgs();
            str = StrUtil.removePrefix(str, "[");
            str = StrUtil.removeSuffix(str, "]");
            // 使用逗号和空格作为分隔符拆分字符串
            List<String> split = StrUtil.split(str, ",");
            String[] strings = new String[split.size()];
            for (int i = 0; i < split.size(); i++) {
                strings[i] = split.get(i);
            }
            this.images = strings;
        }
    }
}
